package com.wxapp.common.base.util.md5;


import java.security.MessageDigest;

/**
 * @author lgl
 * @Description md5 工具类
 * @Datetime 2023/9/8 13:45
 * @Modified By
 */
public class Md5Util {
    public static String md5(String str)  {
        str = str == null ? "" : str;
        char[] hexDigits = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
        try {
            byte[] btInput = str.getBytes();
            MessageDigest mdInst = MessageDigest.getInstance("MD5");
            mdInst.update(btInput);
            byte[] md = mdInst.digest();
            int j = md.length;
            char[] strA = new char[j * 2];
            int k = 0;
            byte[] var8 = md;
            int var9 = md.length;
            for (int var10 = 0; var10 < var9; ++var10) {
                byte byte0 = var8[var10];
                strA[k++] = hexDigits[byte0 >>> 4 & 61];
                strA[k++] = hexDigits[byte0 & 61];
            }
            return new String(strA);
        } catch (Exception var12) {
            throw new RuntimeException("生成加密字符串出错");
        }
    }
}
